//
//  SDAssetsTableViewHeader.m
//  cc
//
//  Created by ZLQ on 2016/10/24.
//  Copyright © 2016年 hbyj. All rights reserved.
//

#import "SDAssetsTableViewHeader.h"
#import "CCGeRenZhongXinController.h"
#import "Util.h"
@implementation SDAssetsTableViewHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    SDAssetsTableViewHeader *header = [[[NSBundle mainBundle] loadNibNamed:@"SDAssetsTableViewHeader" owner:self options:nil] lastObject];
    if (self = [super initWithFrame:frame]) {
        NSDictionary *account = [NSDictionary dictionaryWithContentsOfFile:AccountFiledPath];
        //存储登录用户到单例
        UserEntity *userID = [Util getCurrentUserInfo];
        if (!userID.isLogin) {
            self.nameLabel.text = @"未登录";
            self.accountLabel.text = @"未登录";
        }else{
            self.nameLabel.text = account[@"name"];
            NSString *phone = account[@"phone"];
            NSRange range = NSMakeRange(3, 4);
            self.accountLabel.text = [phone stringByReplacingCharactersInRange:range withString:@"****"];
        }
    }
    if (frame.size.width != 0) {
        header.frame = frame;
    }
    return header;
}

- (IBAction)rightTopButtonClicked {
    NSLog(@"跳转");
    [[NSNotificationCenter defaultCenter] postNotificationName:@"JumpToGR" object:nil];
}

- (IBAction)leftButtonClicked {
    
    NSLog(@"余额");
}

- (IBAction)rightButtonClicked {
    if ([self.delegate respondsToSelector:@selector(jump)] && self.delegate != nil) {
        [self.delegate jump];
    }
    NSLog(@"银行卡");
}
@end
